# recognition/actions/swipe_up.py
from .swipe_base import SwipeBase
import math

class SwipeUp(SwipeBase):
    label = "swipe_up"
    def direction_ok(self, dx, dy):
        ax, ay = abs(dx), abs(dy)
        mag = math.hypot(dx, dy) + 1e-8
        cos = (-dy) / mag  # y 负向为上（以图像坐标 y 向下为正时）
        main_is_y = ay >= ax
        ok = (dy < 0) and main_is_y
        align = max(0.0, min(1.0, cos))
        return ok, align
    